package com.tinama.jedis01.stream;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author lgc
 * @createDate 2020/10/14 - 15:34
 */
public class Demo1 {
    public static void main(String[] args){
        User a = new User(1, "a", 21);
        User b = new User(2, "b", 22);
        User c = new User(3, "c", 23);
        User d = new User(4, "d", 24);
        User e = new User(6, "e", 25);
        List<User> users = Arrays.asList(a, b, c, d, e);
        users.stream()
                .filter((user) -> user.getId() % 2 == 0&&user.getAge()>23)
                .map((u)->{
                     u.setName( u.getName().toUpperCase());
                      return u;})
                .sorted(Comparator.comparing(User::getId).reversed())
                .forEach(System.out::println);
        ;

    }
}
